#ifndef DATA_SORTED_H_
#define DATA_SORTED_H_

#include "stdafx.h"
#include "Document.h"
#include "Category.h"
#include "Dictionary.h"

class DataSorted
{
public:
	void readData(const std::string & fname);
	void writeData(const std::string & fname);

	void addCategory(const std::string & catName);
	size_t getCategoriesCount();
	Category getCategory(uint index);
	void addDocument(const Document & document, const IntVector & indicesOfCategory);

	const Dictionary & getDictionary() const;
	const CategoriesVector & getCategories() const;

private:
	Dictionary myDictionary;
	CategoriesVector myCategories;
};



inline const Dictionary & DataSorted::getDictionary() const {
	return myDictionary;
}

inline const CategoriesVector & DataSorted::getCategories() const {
	return myCategories;
}

inline void DataSorted::addCategory(const std::string & catName) {
	if (myDictionary.getTotalDocuments() > 0) {
		// error
		return;
	}
	myCategories.push_back(catName);
}

inline uint DataSorted::getCategoriesCount() {
	return myCategories.size();
}

inline Category DataSorted::getCategory(uint index) {
	return myCategories[index];
}

inline void DataSorted::addDocument(const Document & document, const IntVector & indicesOfCategory) {
	for (uint i=0; i<indicesOfCategory.size(); ++i) {
		myDictionary.addDocument(document, i);
	}
}

#endif // DATA_SORTED_H_
